package com.example.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mybatisplus.entity.User;
import com.example.mybatisplus.mapper.UserMapper;
import com.example.mybatisplus.service.UserService;
import com.example.mybatisplus.vo.UserVo;
import javafx.scene.control.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Override
    public List<User> listByUserName(String userName) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(User::getUsername, userName);
        List<User> list = baseMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public List<User> allList() {
        return baseMapper.allList();
    }

    /**
     * 测试分页
     * @param page
     * @param username
     * @return
     */
    @Override
    public Page<UserVo> allListByPage(Page page, String username) {
        List<UserVo> list = baseMapper.allListByPage(page, username);
        page.setRecords(list);
        return page;
    }
}
